package com.wxw.websocket.controller;

import com.wxw.websocket.config.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author wxw
 * @data 2021/12/2 16 :48
 * @description
 */
@RestController
public class testWebSocket {
    @Autowired
    private WebSocketServer webSocketServer;
    @PostMapping("/sendAllWebSocket")
    public String test() {
        String text="你们好！这是websocket群体发送！";
        try {
            webSocketServer.sendInfo(text,null);
        }catch (IOException e){
            e.printStackTrace();
        }
        return text;
    }

}
